//
//  AFHTTPNetGetData.m
//  EveryDayNews
//
//  Created by 徐继垚 on 14/11/29.
//  Copyright (c) 2014年 徐继垚. All rights reserved.
//

#import "AFHTTPNetGetData.h"
#import "AFNetworking.h"
@implementation AFHTTPNetGetData
-(void)getDataURL:(NSString *)url parameters:(NSDictionary *)parameters block:(MyBlock)block
{
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    //解密http 遇到这种加密方式就解密
    manager.securityPolicy.allowInvalidCertificates = YES;
    //遇到以下格式返回  json 序列号
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/json",@"application/json",@"text/jacascript",@"text/html",@"text/css",@"text/plain", nil]];
    [manager GET:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        self.block = block;
        self.block(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@", error);
        UIAlertView * alert =[ [UIAlertView alloc]initWithTitle:@"提示" message:@"HTTP请求错误,请检查网络!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [ alert show];
    }];
    
}
+ (void)connectNetGetDataWithURLString:(NSString *)urlStr parameters:(NSDictionary *)parameters  block:(MyBlock)block
{
    AFHTTPNetGetData * data = [[AFHTTPNetGetData alloc]init];
    [data getDataURL:urlStr parameters:parameters block:block];
}




@end
